<?php

require('init.php');
$title = 'Current contest';
require(LIBWWWDIR . '/header.php');

$is_post = $cdata['post'];
if( $is_post== 1 AND (strcmp(now(), $cdata['starttime']) >= 0 && strcmp(now(), $cdata['endtime']) < 0) )
{
	echo "<h1>".$cdata['contestname']."</h1><br>";
	//buscar problemas del actual contest en db1
	$problems= exist("cid", $cdata['cid'], "problem", $conn_db1);

	if( $problems[0] > 0 )
	{
		echo "<table class=\"list sortable\">\n<thead>\n" .
			"<tr><th scope=\"col\">Problem</th><th scope=\"col\">Statement&nbsp;&nbsp;</th>" .	
			"<th scope=\"col\">Source Code&nbsp;&nbsp;</th>" .
			"<th scope=\"col\">Comments</th>" .
			"</tr></thead>\n<tbody>\n"; 

		for($i=1; $i<=$problems[0]; $i++)
		{
			echo  '<tr><td class="probid" >' .
			( !empty($problems[$i]['color']) ?
			  '<img style="background-color: ' . htmlspecialchars($problems[$i]['color']) .
			  ';" alt="problem colour ' . htmlspecialchars($problems[$i]['color']) .
			  '" src="../images/circle.png" /> ' : '' ) . 
			htmlspecialchars($problems[$i]['probid']) ."</a></td><td align=\"center\">".
			show_pdf( $problems[$i]['probid'], $conn_db1, $conn_db2, $cid )."</td><td align=\"center\">".
			show_link_sc($problems[$i]['probid'],$cdata['cid'],$conn_db2)."</td><td align=\"center\">".
			total_comments($problems[$i]['probid'],$cdata['cid'],$conn_db2)."</td></tr>";
		}	
	}else{
		echo "<p class=\"nodata\">No problems defined</p>\n\n";
	}
	echo "</tbody>\n</table>\n\n";	
}else{
		echo "<br>";
		echo "<p class=\"nodata\">No active Postmaraton</p>";
}

require(LIBWWWDIR . '/footer.php');
